<!--#Include File="../conn.asp" -->
<!--#Include File="comm/inc.asp" -->
<%
'====================================================================
'= Team Elite - Elite Article System
'= Copyright (c) 2005 - 2006 Eason Chan All Rights Reserved.
'=-------------------------------------------------------------------
'= 版权协议：
'=	GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
'=-------------------------------------------------------------------
'= 文件名称：/Manager/Admin_Link.asp
'= 摘    要：后台-联盟管理文件
'=-------------------------------------------------------------------
'= 最后更新：eason007
'= 最后日期：2005-12-21
'====================================================================

Call EA_Manager.Chk_IsMaster

If Not EA_Manager.Chk_Power(Admin_Power,"02") Then 
	ErrMsg=str_Comm_NotAccess
	Call EA_Manager.Error(1)
End If

Dim Atcion
Atcion=Request.QueryString ("atcion")

Select Case LCase(Atcion)
Case "add"
	Call Add
Case "save"
	Call Save
Case "del"
	Call Del
Case Else
	Call Main
End Select
Call EA_Pub.Close_Obj
Set EA_Pub=Nothing

Sub Main
	Dim Count,PageCount,Page,OutStr,i
	Dim FieldName(1),FieldValue(1),TopicList
	Dim Temp,ListBlock
	
	Page=EA_Pub.SafeRequest(3,"page",0,1,0)

	PageContent=Template.LoadTemplate("admin_friend_list.htm")


	Template.SetVariable "Language_Comm_ListEmpty",str_Comm_ListEmpty,PageContent
	Template.SetVariable "Language_Comm_Bar_Operation",str_Comm_Bar_Operation,PageContent
	Template.SetVariable "Language_Comm_Edit_Operation",str_Comm_Edit_Operation,PageContent
	Template.SetVariable "Language_Comm_Alert_Del_Operation",str_Comm_Alert_Del_Operation,PageContent
	Template.SetVariable "Language_Comm_Del_Operation",str_Comm_Del_Operation,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Friend_Help",str_Friend_Help,PageContent

	Template.SetVariable "Language_Friend_Order",str_Friend_Order,PageContent
	Template.SetVariable "Language_Friend_SiteName",str_Friend_SiteName,PageContent
	Template.SetVariable "Language_Friend_SiteLogo",str_Friend_SiteLogo,PageContent
	Template.SetVariable "Language_Friend_SiteURL",str_Friend_SiteURL,PageContent
	Template.SetVariable "Language_Friend_Location",str_Friend_Location,PageContent
	Template.SetVariable "Language_Friend_State",str_Friend_State,PageContent
	Template.SetVariable "Language_Friend_LinkList",str_Friend_LinkList,PageContent
	Template.SetVariable "Language_Friend_AddLink",str_Friend_AddLink,PageContent


	ListBlock=Template.GetBlock("list",PageContent)

	Count=EA_M_DBO.Get_Friend_Total()(0,0)
	If Count>0 Then 
		Template.SetVariable "ListTempty","none",PageContent

		TopicList=EA_M_DBO.Get_Friend_List(Page,15)
	
	    For i=0 To Ubound(TopicList,2)
			Temp=ListBlock
  
			Template.SetVariable "SiteID",TopicList(0,i),Temp
			Template.SetVariable "SiteName",TopicList(1,i),Temp
			If Len(TopicList(2,i))>0 Then
				Template.SetVariable "SiteImg",TopicList(2,i),Temp
			Else
				Template.SetVariable "SiteImg","images/space.GIF",Temp
			End If
			Template.SetVariable "SiteURL",TopicList(3,i),Temp
			Template.SetVariable "Location",TopicList(4,i),Temp
			Template.SetVariable "Order",TopicList(5,i),Temp
			Template.SetVariable "State",TopicList(6,i),Temp

			Template.SetBlock "list",Temp,PageContent
		Next

		Template.SetVariable "PageListNav",EA_Manager.PageList(15,Count,Page,FieldName,FieldValue),PageContent
	End If
	Template.CloseBlock "list",PageContent


	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Add
	Dim PostId,Level,Temp,ColumnList
	Dim LinkName,LinkURL,LinkImgPath,LinkInfo,ColumnId,OrderNum,State,Style
	Dim i
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	LinkImgPath="http://www.54nb.com/images/NB_LOGO_S.gif"
	OrderNum=0
	
	Temp=EA_M_DBO.Get_Friend_Info(PostId)
	If IsArray(Temp) Then 
		LinkName=Temp(0,0)
		LinkURL=Temp(1,0)
		LinkImgPath=Temp(2,0)
		LinkInfo=Temp(3,0)
		ColumnId=Temp(4,0)
		OrderNum=Temp(5,0)
		State=Temp(6,0)
		Style=Temp(7,0)
	End If

	Temp=EA_DBO.Get_Column_List()
	If IsArray(Temp) Then
		For i=0 To UBound(Temp,2)
			Level=(Len(Temp(2,i))/4-1)*3
			ColumnList = ColumnList & "<option value="""&Temp(0,i)&""""
			If ColumnId<>"" Then 
				If Cint(ColumnId)=Cint(Temp(0,i)) Then ColumnList = ColumnList & " selected"
			End If
			ColumnList = ColumnList & ">"
			ColumnList = ColumnList & "├"
			ColumnList = ColumnList & String(Level,"-")
			ColumnList = ColumnList & Temp(1,i)&"</option>"
		Next
	End If
	Set Rs=Nothing

	PageContent=Template.LoadTemplate("admin_friend_option.htm")


	Template.SetVariable "Language_Comm_Save_Button",str_Comm_Save_Button,PageContent
	Template.SetVariable "Language_Comm_Reset_Button",str_Comm_Reset_Button,PageContent
	Template.SetVariable "Language_Comm_State_Pass",str_Comm_State_Pass,PageContent
	Template.SetVariable "Language_Comm_State_NoPass",str_Comm_State_NoPass,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Friend_Help",str_Friend_Help,PageContent

	Template.SetVariable "ColumnList",ColumnList,PageContent

	Template.SetVariable "Language_Friend_LinkList",str_Friend_LinkList,PageContent
	Template.SetVariable "Language_Friend_AddLink",str_Friend_AddLink,PageContent
	Template.SetVariable "Language_Friend_Order",str_Friend_Order,PageContent
	Template.SetVariable "Language_Friend_SiteName",str_Friend_SiteName,PageContent
	Template.SetVariable "Language_Friend_SiteLogo",str_Friend_SiteLogo,PageContent
	Template.SetVariable "Language_Friend_SiteURL",str_Friend_SiteURL,PageContent
	Template.SetVariable "Language_Friend_SiteInfo",str_Friend_SiteInfo,PageContent
	Template.SetVariable "Language_Friend_Location",str_Friend_Location,PageContent
	Template.SetVariable "Language_Friend_State",str_Friend_State,PageContent
	Template.SetVariable "Language_Friend_Style",str_Friend_Style,PageContent
	Template.SetVariable "Language_Friend_Style_Txt",str_Friend_Style_Txt,PageContent
	Template.SetVariable "Language_Friend_Style_Img",str_Friend_Style_Img,PageContent
	Template.SetVariable "Language_Friend_Input_Info",str_Friend_Input_Info,PageContent

	Template.SetVariable "LinkName",LinkName,PageContent
	If Len(LinkImgPath)>0 Then
		Template.SetVariable "LinkImgPath",LinkImgPath,PageContent
	Else
		Template.SetVariable "LinkImgPath","images/space.GIF",PageContent
	End If
	Template.SetVariable "SiteID",PostId,PageContent
	Template.SetVariable "LinkURL",LinkURL,PageContent
	Template.SetVariable "LinkInfo",LinkInfo,PageContent
	Template.SetVariable "OrderNum",OrderNum,PageContent
	Template.SetVariable "State_" & Abs(State)," selected",PageContent
	Template.SetVariable "Style_" & CInt(Style)," selected",PageContent


	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Save
	Call EA_Pub.Chk_Post
	
	Dim LinkName,LinkURL,LinkImgPath,LinkInfo,ColumnId,OrderNum,State,Style
	Dim PostId
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	LinkName=EA_Pub.SafeRequest(2,"name",1,"",1)
	LinkURL=EA_Pub.SafeRequest(2,"url",1,"",1)
	LinkImgPath=EA_Pub.SafeRequest(2,"img",1,"",1)
	LinkInfo=EA_Pub.SafeRequest(2,"info",1,"",1)
	ColumnId=EA_Pub.SafeRequest(2,"column",0,0,0)
	OrderNum=EA_Pub.SafeRequest(2,"order",0,0,0)
	State=EA_Pub.SafeRequest(2,"state",0,0,0)
	Style=EA_Pub.SafeRequest(2,"style",0,0,0)
	
	If LinkName="" Or Len(LinkName)>50 Then
		ErrMsg="对不起，联盟网站的名称长度不符！"
		ErrMsg=ErrMsg&"<li>长度等于0或大于50"
		Call EA_Manager.Error(1)
	End If
	If LinkURL="" Or Len(LinkURL)>150 Then
		ErrMsg="对不起，联盟网站的连接地址长度不符！"
		ErrMsg=ErrMsg&"<li>长度等于0或大于150"
		Call EA_Manager.Error(1)
	End If
	If Style="1" Then 
		If LinkImgPath="" Or Len(LinkImgPath)>150 Then
			ErrMsg="对不起，联盟网站的图片地址长度不符！"
			ErrMsg=ErrMsg&"<li>长度等于0或大于150"
			Call EA_Manager.Error(1)
		End If
	End If
		
	If Rs.State=1 Then rs.Close
	If PostId<>0 Then
		Sql="Select * From [NB_FriendLink] Where [Id]="&PostId
		rs.Open Sql,Conn,2,2
	Else
		rs.Open "NB_FriendLink",Conn,2,2
		rs.AddNew
	End If
		rs("LinkName")=LinkName
		rs("LinkUrl")=LinkURL
		rs("LinkImgPath")=LinkImgPath
		rs("LinkInfo")=LinkInfo
		rs("ColumnId")=ColumnId
		rs("OrderNum")=OrderNum
		rs("State")=State
		rs("Style")=Style
		rs.update
	Rs.Close:Set Rs=Nothing
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect "admin_friend.asp"
End Sub

Sub Del
	Call EA_Pub.Chk_Post
	
	Dim PostId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	
	EA_M_DBO.Set_Friend_Delete PostId
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Sub
%>